package com.tuoren.forward.util;

import java.util.List;

import com.tuoren.forward.constant.CodeMsg;


public class ResultPage<T> extends Result {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 3489569165186783333L;
	private Long total;
	private List<T> data;
	public Long getTotal() {
		return total;
	}
	public void setTotal(Long total) {
		this.total = total;
	}
	public List<T> getData() {
		return data;
	}
	public void setData(List<T> data) {
		this.data = data;
	}
	public ResultPage(CodeMsg codeMsg) {
		super(codeMsg);
		// TODO Auto-generated constructor stub
	}
	
	public static<T> ResultPage<T> success(List<T> data){
		ResultPage<T> result = new ResultPage<T>(CodeMsg.SUCCESS);
		result.setData(data);
		return result;
	}
	
	public static<T> ResultPage<T> success(List<T> data,Long total){
		ResultPage<T> result = new ResultPage<T>(CodeMsg.SUCCESS);
		result.setData(data);
		result.setTotal(total);
		return result;
	}
	
	public static<T> ResultPage<T> failNull(){
		ResultPage<T> result = new ResultPage<T>(CodeMsg.FAILURE);
		return result;
	}
	
	public static<T> ResultPage<T> failNull(String message){
		ResultPage<T> result = new ResultPage<T>(CodeMsg.FAILURE);
		result.setMsg(message);
		return result;
	}
	
	public static<T> ResultPage<T> fail(List<T> data){
		ResultPage<T> result = new ResultPage<T>(CodeMsg.FAILURE);
		result.setData(data);
		return result;
	}
	

}
